<%@ page language="java" contentType="text/html; charset=utf-8" %>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page"/>
<%@ page import="com.alibaba.fastjson.JSONArray" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="weaver.common.DateUtil" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.BaseBean" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="weaver.hrm.resource.ResourceComInfo" %>
<%@ page import="weaver.interfaces.linearin.duss.utils.KingdeeUtil" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Map" %>
<%
    JSONObject jsonData = new JSONObject();
    BaseBean baseBean = new BaseBean();
    JSONObject dataJson = new JSONObject();
    RecordSet rs1 = new RecordSet();
    try {
        ResourceComInfo comInfo = new ResourceComInfo();
        String ids = Util.null2String(request.getParameter("ids"));
        baseBean.writeLog(">>>>>getScbzByFttz_Ajax.jsp>>>>>ids=" + ids);
        String currentDate = DateUtil.getCurrentDate();
        int totalcount = ids.split(",").length;
        int succcount = 0;
        int failcount = 0;
        int succcount1 = 0;
        int succcount2 = 0;
        int succcount3 = 0;
        for (String mainid : ids.split(",")) {
            //发票挂账
            String sql = "select sybu from uf_fttz_dt1 where mainid=? and isnull(sybu,'') !='' group by sybu";
            rs.executeQuery(sql, mainid);
            int fpgz_totalcount = rs.getCounts();
            int fpgz_failcount = 0;
            while (rs.next()) {
                String sybu = Util.null2String(rs.getString("sybu"));
                String bookid = KingdeeUtil.getBookId(sybu);
                //单据体：FEntity
                JSONArray FEntity = new JSONArray();
                /*单据体第一行*/
                rs1.executeQuery("select gys,ysfymc,jdbmbm,hjkm,je from uf_fttz_dt1 where mainid=? and sybu=? ", mainid, sybu);
                while (rs1.next()) {
                    String gys = Util.null2String(rs1.getString("gys"));
                    String ysfymc = Util.null2String(rs1.getString("ysfymc"));
                    String jdbmbm = Util.null2String(rs1.getString("jdbmbm"));
                    String hjkm = Util.null2String(rs1.getString("hjkm"));
                    String je = Util.null2String(rs1.getString("je"));
                    if (Util.getDoubleValue(je) > 0) {
                        JSONObject FEntityJSON = new JSONObject();
                        //摘要
                        String fexplanation = "应付-" + KingdeeUtil.getGysmc(gys) + "-" + KingdeeUtil.getYskmmc(ysfymc);
                        FEntityJSON.put("FEXPLANATION", fexplanation);
                        //科目编码
                        JSONObject FACCOUNTID = new JSONObject();
                        FACCOUNTID.put("FNumber", hjkm);
                        FEntityJSON.put("FACCOUNTID", FACCOUNTID);
                        //核算维度
                        JSONObject FDetailID = new JSONObject();
                        //金蝶部门编码
                        if (!"".equals(jdbmbm)) {
                            JSONObject FDETAILID__FFLEX5 = new JSONObject();
                            FDETAILID__FFLEX5.put("FNumber", jdbmbm);
                            FDetailID.put("FDETAILID__FFLEX5", FDETAILID__FFLEX5);
                        }
                        FEntityJSON.put("FDetailID", FDetailID);
                        //借方金额
                        FEntityJSON.put("FDEBIT", je);
                        FEntity.add(FEntityJSON);
                    }
                }
                /*单据体第二行*/
                rs1.executeQuery("select gys,ysfymc,sum(zfje) zfje from uf_fttz_dt1 " +
                        "where mainid=? and sybu=? group by gys,ysfymc", mainid, sybu);
                while (rs1.next()) {
                    JSONObject FEntityJSON = new JSONObject();
                    String gys = Util.null2String(rs1.getString("gys"));
                    String ysfymc = Util.null2String(rs1.getString("ysfymc"));
                    String zfje = Util.null2String(rs1.getString("zfje"));
                    if (Util.getDoubleValue(zfje) > 0) {
                        //摘要
                        String fexplanation = "应付-" + KingdeeUtil.getGysmc(gys) + "-" + KingdeeUtil.getYskmmc(ysfymc);
                        FEntityJSON.put("FEXPLANATION", fexplanation);
                        //科目编码
                        JSONObject FACCOUNTID = new JSONObject();
                        FACCOUNTID.put("FNumber", "2241.02");
                        FEntityJSON.put("FACCOUNTID", FACCOUNTID);
                        //核算维度
                        JSONObject FDetailID = new JSONObject();
                        //业务单位名称
                        JSONObject FDETAILID__FFLEX4 = new JSONObject();
                        FDETAILID__FFLEX4.put("FNumber", KingdeeUtil.getGysBm(gys));
                        FDetailID.put("FDETAILID__FFLEX4", FDETAILID__FFLEX4);
                        FEntityJSON.put("FDetailID", FDetailID);
                        //贷方金额
                        FEntityJSON.put("FCREDIT", zfje);
                        FEntity.add(FEntityJSON);
                    }

                }
                dataJson.put("zfrq", currentDate);
                dataJson.put("FEntity", FEntity);
                baseBean.writeLog(">>>>>getScbzByFttz_Ajax.jsp>>>>>dataJson=" + dataJson.toJSONString());
                Map<String, Object> dataMap = new HashMap<>();
                dataMap.put("jkdymc", "WeaFpgzlcSYBAction");
                dataMap.put("lcid", mainid);
                dataMap.put("dylc", mainid);
                dataMap.put("bookid", bookid);
                dataMap.put("cz", "batchsubmit");
                JSONObject resultJson = KingdeeUtil.passCertificate(dataJson, dataMap);
                baseBean.writeLog(">>>>>getScbzByFttz_Ajax.jsp>>>>>resultJson=" + resultJson.toJSONString());
                String code = Util.null2String(resultJson.getString("code"));
                if ("success".equals(code)) {
                    String dataStr = Util.null2String(resultJson.getString("data"));
                    JSONObject retrunDataJson = JSONObject.parseObject(dataStr);
                    JSONObject ResultJson = JSONObject.parseObject(retrunDataJson.getString("Result"));
                    JSONObject ResponseStatusJson = JSONObject.parseObject(ResultJson.getString("ResponseStatus"));
                    String IsSuccess = Util.null2String(ResponseStatusJson.getString("IsSuccess"));
                    if ("false".equals(IsSuccess)) {
                        fpgz_failcount++;
                    }
                } else {
                    fpgz_failcount++;
                }
            }
            baseBean.writeLog(">>>>>getScbzByFttz_Ajax.jsp>>>发票挂账>>>>>totalcount=" + fpgz_totalcount +
                    ",failcount=" + fpgz_failcount + ",succcount=" + (fpgz_totalcount - fpgz_failcount));
            if (fpgz_failcount <= 0) {
                succcount1++;
            }
            //费用报销
            rs.executeQuery("select sybu from uf_fttz_dt2 where mainid=? and isnull(sybu,'') !='' group by sybu", mainid);
            int fybx_totalcount = rs.getCounts();
            int fybx_failcount = 0;
            while (rs.next()) {
                String sybu = Util.null2String(rs.getString("sybu"));
                String bookid = KingdeeUtil.getBookId(sybu);
                //单据体：FEntity
                JSONArray FEntity = new JSONArray();
                /*单据体第一行*/
                rs1.executeQuery("select ry,ysfymc,hjkm,jdbmbm,jdrybm,sum(bxftje) bxftje from uf_fttz_dt2 " +
                        "where mainid=? and sybu=? group by ry,ysfymc,hjkm,jdbmbm,jdrybm", mainid, sybu);
                while (rs1.next()) {
                    JSONObject FEntityJSON = new JSONObject();
                    String ry = Util.null2String(rs1.getString("ry"));
                    String hjkm = Util.null2String(rs1.getString("hjkm"));
                    String ysfymc = Util.null2String(rs1.getString("ysfymc"));
                    String jdbmbm = Util.null2String(rs.getString("jdbmbm"));
                    String jdrybm = Util.null2String(rs.getString("jdrybm"));
                    String bxftje = Util.null2String(rs1.getString("bxftje"));
                    if (Util.getDoubleValue(bxftje) > 0) {
                        //摘要
                        String fexplanation = comInfo.getLastname(ry) + "-报销-" + KingdeeUtil.getYskmmc(ysfymc);
                        FEntityJSON.put("FEXPLANATION", fexplanation);
                        //科目编码
                        JSONObject FACCOUNTID = new JSONObject();
                        FACCOUNTID.put("FNumber", hjkm);
                        FEntityJSON.put("FACCOUNTID", FACCOUNTID);
                        //核算维度
                        JSONObject FDetailID = new JSONObject();
                        //金蝶部门编码
                        if (!"".equals(jdbmbm)) {
                            JSONObject FDETAILID__FFLEX5 = new JSONObject();
                            FDETAILID__FFLEX5.put("FNumber", jdbmbm);
                            FDetailID.put("FDETAILID__FFLEX5", FDETAILID__FFLEX5);
                        }
                        //金蝶人员编码
                        if (!"".equals(jdrybm)) {
                            JSONObject FDETAILID__FFLEX7 = new JSONObject();
                            FDETAILID__FFLEX7.put("FNumber", jdrybm);
                            FDetailID.put("FDETAILID__FFLEX7", FDETAILID__FFLEX7);
                        }

                        FEntityJSON.put("FDetailID", FDetailID);
                        //借方金额
                        FEntityJSON.put("FDEBIT", bxftje);
                        FEntity.add(FEntityJSON);
                    }
                }
                /*单据体第二行*/
                rs1.executeQuery("select ry,jdrybm,bxftje from uf_fttz_dt2 where mainid=? and sybu=?", mainid, sybu);
                while (rs1.next()) {
                    JSONObject FEntityJSON = new JSONObject();
                    String ry = Util.null2String(rs1.getString("ry"));
                    String jdrybm = Util.null2String(rs1.getString("jdrybm"));
                    String bxftje = Util.null2String(rs1.getString("bxftje"));
                    if (Util.getDoubleValue(bxftje) > 0) {
                        //摘要
                        String fexplanation = comInfo.getLastname(ry) + "-报销费用";
                        FEntityJSON.put("FEXPLANATION", fexplanation);
                        //科目编码
                        JSONObject FACCOUNTID = new JSONObject();
                        FACCOUNTID.put("FNumber", "2241.03");
                        FEntityJSON.put("FACCOUNTID", FACCOUNTID);
                        //核算维度
                        JSONObject FDetailID = new JSONObject();
                        //金蝶人员编码
                        if (!"".equals(jdrybm)) {
                            JSONObject FDETAILID__FFLEX7 = new JSONObject();
                            FDETAILID__FFLEX7.put("FNumber", jdrybm);
                            FDetailID.put("FDETAILID__FFLEX7", FDETAILID__FFLEX7);
                        }
                        FEntityJSON.put("FDetailID", FDetailID);
                        //贷方金额
                        FEntityJSON.put("FCREDIT", bxftje);
                        FEntity.add(FEntityJSON);
                    }
                }
                /*单据体第三行*/
                rs1.executeQuery("select ry,jdrybm,zfftje from uf_fttz_dt2 where mainid=? and sybu=?", mainid, sybu);
                while (rs1.next()) {
                    JSONObject FEntityJSON = new JSONObject();
                    String ry = Util.null2String(rs1.getString("ry"));
                    String jdrybm = Util.null2String(rs1.getString("jdrybm"));
                    String zfftje = Util.null2String(rs1.getString("zfftje"));
                    if (Util.getDoubleValue(zfftje) > 0) {
                        //摘要
                        String fexplanation = "支付-" + comInfo.getLastname(ry) + "-报销费用";
                        FEntityJSON.put("FEXPLANATION", fexplanation);
                        //科目编码
                        JSONObject FACCOUNTID = new JSONObject();
                        FACCOUNTID.put("FNumber", "2241.03");
                        FEntityJSON.put("FACCOUNTID", FACCOUNTID);
                        //核算维度
                        JSONObject FDetailID = new JSONObject();
                        //金蝶人员编码
                        if (!"".equals(jdrybm)) {
                            JSONObject FDETAILID__FFLEX7 = new JSONObject();
                            FDETAILID__FFLEX7.put("FNumber", jdrybm);
                            FDetailID.put("FDETAILID__FFLEX7", FDETAILID__FFLEX7);
                        }
                        FEntityJSON.put("FDetailID", FDetailID);
                        //借方金额
                        FEntityJSON.put("FDEBIT", zfftje);
                        FEntity.add(FEntityJSON);
                    }
                }
                /*单据体第四行*/
                rs1.executeQuery("select ry,zfftje from uf_fttz_dt2 where mainid=? and sybu=?", mainid, sybu);
                while (rs1.next()) {
                    JSONObject FEntityJSON = new JSONObject();
                    String ry = Util.null2String(rs1.getString("ry"));
                    String zfftje = Util.null2String(rs1.getString("zfftje"));
                    if (Util.getDoubleValue(zfftje) > 0) {
                        //摘要
                        String fexplanation = "支付-" + comInfo.getLastname(ry) + "-报销费用";
                        FEntityJSON.put("FEXPLANATION", fexplanation);
                        //科目编码
                        JSONObject FACCOUNTID = new JSONObject();
                        FACCOUNTID.put("FNumber", "1002.01");
                        FEntityJSON.put("FACCOUNTID", FACCOUNTID);
                        //核算维度
                        JSONObject FDetailID = new JSONObject();
                        //银行账号
                        JSONObject FDETAILID__FF100006 = new JSONObject();
                        FDETAILID__FF100006.put("FNumber", "121919696310901");
                        FDetailID.put("FDETAILID__FF100006", FDETAILID__FF100006);
                        FEntityJSON.put("FDetailID", FDetailID);
                        //贷方金额
                        FEntityJSON.put("FCREDIT", zfftje);
                        FEntity.add(FEntityJSON);
                    }
                }
                dataJson.put("zfrq", currentDate);
                dataJson.put("FEntity", FEntity);
                baseBean.writeLog(">>>>>getScbzByFttz_Ajax.jsp>>>>>dataJson=" + dataJson.toJSONString());
                Map<String, Object> dataMap = new HashMap<>();
                dataMap.put("jkdymc", "WeaBxsplcSYBAction");
                dataMap.put("lcid", mainid);
                dataMap.put("dylc", mainid);
                dataMap.put("cz", "submit");
                dataMap.put("bookid", bookid);
                JSONObject resultJson = KingdeeUtil.passCertificate(dataJson, dataMap);
                baseBean.writeLog(">>>>>getScbzByFttz_Ajax.jsp>>>>>resultJson=" + resultJson.toJSONString());
                String code = Util.null2String(resultJson.getString("code"));
                if ("success".equals(code)) {
                    String dataStr = Util.null2String(resultJson.getString("data"));
                    JSONObject retrunDataJson = JSONObject.parseObject(dataStr);
                    JSONObject ResultJson = JSONObject.parseObject(retrunDataJson.getString("Result"));
                    JSONObject ResponseStatusJson = JSONObject.parseObject(ResultJson.getString("ResponseStatus"));
                    String IsSuccess = Util.null2String(ResponseStatusJson.getString("IsSuccess"));
                    if ("false".equals(IsSuccess)) {
                        fybx_failcount++;
                    }
                } else {
                    fybx_failcount++;
                }
            }
            if (fybx_failcount <= 0) {
                succcount2++;
            }
            baseBean.writeLog(">>>>>getScbzByFttz_Ajax.jsp>>>费用报销>>>>>totalcount=" + fybx_totalcount +
                    ",failcount=" + fybx_failcount + ",succcount=" + (fybx_totalcount - fybx_failcount));
            //差旅费报销
            rs.executeQuery("select sybu from uf_fttz_dt3 where mainid=? and isnull(sybu,'') !='' group by sybu", mainid);
            int clfbx_totalcount = rs.getCounts();
            int clfbx_failcount = 0;
            while (rs.next()) {
                String sybu = Util.null2String(rs.getString("sybu"));
                String bookid = KingdeeUtil.getBookId(sybu);
                //单据体：FEntity
                JSONArray FEntity = new JSONArray();
                /*单据体第一行*/
                rs1.executeQuery("select ry,ysfymc,hjkm,jdbmbm,jdrybm,sum(bxftje) bxftje from uf_fttz_dt3 " +
                        "where mainid=? and sybu=? group by ry,ysfymc,hjkm,jdbmbm,jdrybm", mainid, sybu);
                while (rs1.next()) {
                    JSONObject FEntityJSON = new JSONObject();
                    String ry = Util.null2String(rs1.getString("ry"));
                    String hjkm = Util.null2String(rs1.getString("hjkm"));
                    String ysfymc = Util.null2String(rs1.getString("ysfymc"));
                    String jdbmbm = Util.null2String(rs.getString("jdbmbm"));
                    String jdrybm = Util.null2String(rs.getString("jdrybm"));
                    String bxftje = Util.null2String(rs1.getString("bxftje"));
                    if (Util.getDoubleValue(bxftje) > 0) {
                        //摘要
                        String fexplanation = comInfo.getLastname(ry) + "-差旅报销-" + KingdeeUtil.getYskmmc(ysfymc);
                        FEntityJSON.put("FEXPLANATION", fexplanation);
                        //科目编码
                        JSONObject FACCOUNTID = new JSONObject();
                        FACCOUNTID.put("FNumber", hjkm);
                        FEntityJSON.put("FACCOUNTID", FACCOUNTID);
                        //核算维度
                        JSONObject FDetailID = new JSONObject();
                        //金蝶部门编码
                        if (!"".equals(jdbmbm)) {
                            JSONObject FDETAILID__FFLEX5 = new JSONObject();
                            FDETAILID__FFLEX5.put("FNumber", jdbmbm);
                            FDetailID.put("FDETAILID__FFLEX5", FDETAILID__FFLEX5);
                        }
                        //金蝶人员编码
                        if (!"".equals(jdrybm)) {
                            JSONObject FDETAILID__FFLEX7 = new JSONObject();
                            FDETAILID__FFLEX7.put("FNumber", jdrybm);
                            FDetailID.put("FDETAILID__FFLEX7", FDETAILID__FFLEX7);
                        }

                        FEntityJSON.put("FDetailID", FDetailID);
                        //借方金额
                        FEntityJSON.put("FDEBIT", bxftje);
                        FEntity.add(FEntityJSON);
                    }
                }
                /*单据体第二行*/
                rs1.executeQuery("select ry,jdrybm,bxftje from uf_fttz_dt3 where mainid=? and sybu=?", mainid, sybu);
                while (rs1.next()) {
                    JSONObject FEntityJSON = new JSONObject();
                    String ry = Util.null2String(rs1.getString("ry"));
                    String jdrybm = Util.null2String(rs1.getString("jdrybm"));
                    String bxftje = Util.null2String(rs1.getString("bxftje"));
                    if (Util.getDoubleValue(bxftje) > 0) {
                        //摘要
                        String fexplanation = comInfo.getLastname(ry) + "-差旅报销-差旅费";
                        FEntityJSON.put("FEXPLANATION", fexplanation);
                        //科目编码
                        JSONObject FACCOUNTID = new JSONObject();
                        FACCOUNTID.put("FNumber", "2241.03");
                        FEntityJSON.put("FACCOUNTID", FACCOUNTID);
                        //核算维度
                        JSONObject FDetailID = new JSONObject();
                        //金蝶人员编码
                        if (!"".equals(jdrybm)) {
                            JSONObject FDETAILID__FFLEX7 = new JSONObject();
                            FDETAILID__FFLEX7.put("FNumber", jdrybm);
                            FDetailID.put("FDETAILID__FFLEX7", FDETAILID__FFLEX7);
                        }
                        FEntityJSON.put("FDetailID", FDetailID);
                        //贷方金额
                        FEntityJSON.put("FCREDIT", bxftje);
                        FEntity.add(FEntityJSON);
                    }
                }
                /*单据体第三行*/
                rs1.executeQuery("select ry,jdrybm,bxftje from uf_fttz_dt3 where mainid=? and sybu=?", mainid, sybu);
                while (rs1.next()) {
                    JSONObject FEntityJSON = new JSONObject();
                    String ry = Util.null2String(rs1.getString("ry"));
                    String jdrybm = Util.null2String(rs1.getString("jdrybm"));
                    String bxftje = Util.null2String(rs1.getString("bxftje"));
                    if (Util.getDoubleValue(bxftje) > 0) {
                        //摘要
                        String fexplanation = "支付-" + comInfo.getLastname(ry) + "-差旅报销-差旅费";
                        FEntityJSON.put("FEXPLANATION", fexplanation);
                        //科目编码
                        JSONObject FACCOUNTID = new JSONObject();
                        FACCOUNTID.put("FNumber", "2241.03");
                        FEntityJSON.put("FACCOUNTID", FACCOUNTID);
                        //核算维度
                        JSONObject FDetailID = new JSONObject();
                        //金蝶人员编码
                        if (!"".equals(jdrybm)) {
                            JSONObject FDETAILID__FFLEX7 = new JSONObject();
                            FDETAILID__FFLEX7.put("FNumber", jdrybm);
                            FDetailID.put("FDETAILID__FFLEX7", FDETAILID__FFLEX7);
                        }
                        FEntityJSON.put("FDetailID", FDetailID);
                        //借方金额
                        FEntityJSON.put("FDEBIT", bxftje);
                        FEntity.add(FEntityJSON);
                    }
                }
                /*单据体第四行*/
                rs1.executeQuery("select ry,zfftje from uf_fttz_dt3 where mainid=? and sybu=?", mainid, sybu);
                while (rs1.next()) {
                    JSONObject FEntityJSON = new JSONObject();
                    String ry = Util.null2String(rs1.getString("ry"));
                    String zfftje = Util.null2String(rs1.getString("zfftje"));
                    if (Util.getDoubleValue(zfftje) > 0) {
                        //摘要
                        String fexplanation = "支付-" + comInfo.getLastname(ry) + "-差旅报销-差旅费";
                        FEntityJSON.put("FEXPLANATION", fexplanation);
                        //科目编码
                        JSONObject FACCOUNTID = new JSONObject();
                        FACCOUNTID.put("FNumber", "1002.01");
                        FEntityJSON.put("FACCOUNTID", FACCOUNTID);
                        //核算维度
                        JSONObject FDetailID = new JSONObject();
                        //银行账号
                        JSONObject FDETAILID__FF100006 = new JSONObject();
                        FDETAILID__FF100006.put("FNumber", "121919696310901");
                        FDetailID.put("FDETAILID__FF100006", FDETAILID__FF100006);
                        FEntityJSON.put("FDetailID", FDetailID);
                        //贷方金额
                        FEntityJSON.put("FCREDIT", zfftje);
                        FEntity.add(FEntityJSON);
                    }
                }
                dataJson.put("zfrq", currentDate);
                dataJson.put("FEntity", FEntity);
                baseBean.writeLog(">>>>>getScbzByFttz_Ajax.jsp>>>>>dataJson=" + dataJson.toJSONString());
                Map<String, Object> dataMap = new HashMap<>();
                dataMap.put("jkdymc", "WeaBxsplcSYBAction");
                dataMap.put("lcid", mainid);
                dataMap.put("dylc", mainid);
                dataMap.put("cz", "submit");
                dataMap.put("bookid", bookid);
                JSONObject resultJson = KingdeeUtil.passCertificate(dataJson, dataMap);
                baseBean.writeLog(">>>>>getScbzByFttz_Ajax.jsp>>>>>resultJson=" + resultJson.toJSONString());
                String code = Util.null2String(resultJson.getString("code"));
                if ("success".equals(code)) {
                    String dataStr = Util.null2String(resultJson.getString("data"));
                    JSONObject retrunDataJson = JSONObject.parseObject(dataStr);
                    JSONObject ResultJson = JSONObject.parseObject(retrunDataJson.getString("Result"));
                    JSONObject ResponseStatusJson = JSONObject.parseObject(ResultJson.getString("ResponseStatus"));
                    String IsSuccess = Util.null2String(ResponseStatusJson.getString("IsSuccess"));
                    if ("false".equals(IsSuccess)) {
                        clfbx_failcount++;
                    }
                } else {
                    clfbx_failcount++;
                }
            }
            if (clfbx_failcount <= 0) {
                succcount3++;
            }
            baseBean.writeLog(">>>>>getScbzByFttz_Ajax.jsp>>>差旅费报销>>>>>totalcount=" + clfbx_totalcount +
                    ",failcount=" + clfbx_failcount + ",succcount=" + (clfbx_totalcount - clfbx_failcount));

            if (succcount1 > 0 && succcount2 > 0 && succcount3 > 0) {
                succcount++;
            } else {
                failcount++;
            }
        }
        jsonData.put("totalcount", totalcount);
        jsonData.put("succcount", succcount);
        jsonData.put("failcount", failcount);
    } catch (Exception e) {
        e.printStackTrace();
    }
    out.print(jsonData.toJSONString());
%>
